<?php


namespace app\admin\model;
use think\Model;
use think\Request;

class Food extends Model
{
    protected $table = 'food';
    public function addEmp($data)
    {
        $this->save($data);
    }
    public function getList($search='')
    {
//        $params = array_merge([
//            'food_id' => 0,
//            'food_title' => '',
//            'search' => ''
//        ], $param);
//        $filters = [];
        //精确查找
//        $params['food_id'] > 0 && $filters['food_id'] = $params['food_id'];
//        !empty($params['food_title']) && $filters['food_title'] = $params['food_title'];
        //搜索
        !empty($search) && $this->where('food_content|food_title', 'like', "%$search%");

//        $this->where($filters);
        return $this->paginate(10, false, [
                'query' => Request::instance()->request()
            ]);
    }

    public function delfood($no){
        return $this->where('food_id',$no)->delete();
    }
}
